<?php

namespace app\yiluqianxing\admin;

use app\admin\controller\Admin;
use app\common\builder\ZBuilder;
use think\Db;

class Useradmin extends Admin {

    //雨情跑步 用户管理
    function index(){
        $map = $this->getMap();

        $data=Db::table('dp_ylqx_user')
            ->order('id desc')
            ->where($map)
            ->paginate(10)
            ->each(function ($item, $key){
                $item['point']=Db::table('dp_ylqx_uploads')
                    ->where('openid',$item['openid'])
                    ->sum('plus_point');
                return $item;
            });
        return ZBuilder::make('table')
            ->addColumns([ // 批量添加列
                ['avatarurl', '用户头像','img_url'],
                ['nickname', '用户名'],
                ['point', '用户点数'],
                ['time','注册时间','datetime']
            ])
            ->setSearch(['nickname' => '用户名']) // 设置搜索参数
            ->setRowList($data) // 设置表格数据
            ->fetch();
    }
}